<?php

class Empresa extends DBAbstractModel {

    public $id_empresa;
    public $uso;
    public $control;
    public $nombre;

    function save() {
        $this->query = '';
        $this->query = "INSERT INTO empresas (uso,control,nombre) VALUES ";
        $this->query.="('$this->uso','$this->control','$this->nombre');";
        echo "query insertar: " . $this->query . "</br>";
        $this->execute_single_query();
    }

    function delete($key) {

        $this->query = '';
        $this->query = "DELETE FROM empresas WHERE nombre='$key'";
        echo "query eliminar: " . $this->query . "</br>";
        $this->execute_single_query();
    }

    function update($key) {
        $this->query = '';
        $this->query = "UPDATE  empresas SET nombre='$this->nombre',";
        $this->query.=" uso='$this->uso', control='$this->control' WHERE  nombre='$key'";

        echo "query actualizar: " . $this->query . "</br>";
        $this->execute_single_query();
    }

   function get($key) {
        if ($key != ''):
            $this->query = "SELECT *FROM empresas WHERE nombre = '$key'";
            $this->get_results_from_query();
        endif;
    }
    function getAll() {
        $this->query = "SELECT *FROM empresas";
        $this->get_results_from_query();
    }

}

?>
  